﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using CMS.BLL;


public partial class Controls_Common_ctrTourNavigation : System.Web.UI.UserControl
{
    private int nCurrentLanguage = Support.GetCurrentLanguage(); 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            this.SetLabel();
        }
    }
  

    private void SetLabel()
    {
        lnkHome.Text = MultipleLanguage.HOME[nCurrentLanguage - 1];
        int nCountry = this.GetCountry();
        //lnkTours.Text = MultipleLanguage.TOUR[nCurrentLanguage - 1];
        if (nCountry ==0)
            nCountry=1;
        switch (nCountry )
        {
            case 1:
                lnkCountry.Text = "Vietnam";
                lnkCountry.NavigateUrl = "~/Default.aspx?cid=1";
                lnkHome.NavigateUrl = "~/Default.aspx?cid=1";
               // lnkTours.NavigateUrl = "~/Tours.aspx?cid=1";
                break;
            case 2:
                lnkCountry.Text = "Laos";
                lnkCountry.NavigateUrl = "~/Default.aspx?cid=2";
                lnkHome.NavigateUrl = "~/Default.aspx?cid=2";
                //lnkTours.NavigateUrl = "~/Tours.aspx?cid=2";
                break;
            case 3:
                lnkCountry.Text = "Cambodia";
                lnkCountry.NavigateUrl = "~/Default.aspx?cid=3";
                lnkHome.NavigateUrl = "~/Default.aspx?cid=3";
                //lnkTours.NavigateUrl = "~/Tours.aspx?cid=3";
                break;
        }
        
         int nTourCat = ConvertData.ConvertToInt(Request.QueryString[Config.TOUR_CAT]);
        int nSalesOff= ConvertData.ConvertToInt(Request.QueryString[Config.TOUR_SALEOFF]);
        int nPopular = ConvertData.ConvertToInt(Request.QueryString[Config.TOUR_POPULAR]);


        // Show Tour Cat
        if (nTourCat > 0 && nSalesOff == 0 && nPopular == 0)
        {
            ltrTourCat.Visible = true;
            TourCategory objTourCat = new TourCategory();
            objTourCat.LoadById(nTourCat);
            switch (nCurrentLanguage)
            {
                case 1:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName1;
                    break;
                case 2:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName2;
                    break;
                case 3:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName3;
                    break;
            }
        }

        // Show Sale Off
        if (nTourCat == 0 && nSalesOff > 0 && nPopular == 0)
        {
            SaleOff objSaleOff = new SaleOff();
            objSaleOff.LoadById(nSalesOff);
            switch (nCurrentLanguage)
            {
                case 1:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objSaleOff.Data.Title1;
                    break;
                case 2:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objSaleOff.Data.Title2;
                    break;
                case 3:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objSaleOff.Data.Title3;
                    break;
            }
        }

        //show popular
         if (nTourCat == 0 && nSalesOff == 0 && nPopular > 0)
        {
            TourPopular objTourPopular = new TourPopular();
            objTourPopular.LoadById(nPopular);
            switch (nCurrentLanguage)
            {
                case 1:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourPopular.Data.Description1;
                    break;
                case 2:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourPopular.Data.Description2;
                    break;
                case 3:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourPopular.Data.Description3;
                    break;
            }
        }

        // Empty
        if (nTourCat == 0 && nSalesOff == 0 && nPopular == 0)
        {      
            TourCategory objTourCat = new TourCategory();
            DataTable dtbCat = new DataTable();


            dtbCat = objTourCat.Search(0, this.GetCountry());
                  
                nTourCat = ConvertData.ConvertToInt(dtbCat.Rows[0]["TourCategoryID"]);
                 
            objTourCat.LoadById(nTourCat);

            switch (nCurrentLanguage)
            {
                case 1:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName1;
                    break;
                case 2:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName2;
                    break;
                case 3:
                    ltrTourCat.Text = "<img src=\"images/Layout/ico-bullet-3.png\" />" + objTourCat.Data.TourCategoryName3;
                    break;
            }
        }
       
       
    }

    private int GetCountry()
    {
        int nCountry = 0;
        nCountry = ConvertData.ConvertToInt(Request.QueryString[Config.COUNTRY]);
        if (nCountry == 0)
            nCountry = Config.COUNTRY_DEFAULT;
        return nCountry;
    }

}